﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FairyGUI;
using UnityEngine;
using Assets.game;
namespace Assets
{
    class ClientMessage
    {
        public static void message(string content, SocketClient theClient)
        {
            Debug.Log(content);
            Message msg = JsonUtility.FromJson<Message>(content);
            if (msg.type == MessageType.ONLINE_FULL)
            {
                Loom.QueueOnMainThread((param) =>
                {
                    Root.instance.com.GetChild("error").asTextField.text = "服务器已满，暂时无法进入";
                    Root.instance.com.GetChild("n9").enabled = true;
                }, null);
                theClient.Close();
            }
            else if (msg.type == MessageType.JOIN_GAME)
            {
               
                //开始游戏
                Loom.QueueOnMainThread((param) =>
                {
                    Root.instance.startGame();
                }, null);

            }
            else if (msg.type == MessageType.START_ROOM)
            {
                
                Loom.QueueOnMainThread((param) =>
                {
                    Root.instance.startRoom(msg.intParas,msg.cards);
                }, null);
            }
        }

       
    }
}
